import Request from "./../../core";

// ******************* 规格相关 *****************
// 添加规格
export const addSpec = (data) => {
  return Request.get(`/mall/admin/spec/spec_id`, data, {
    isLoading: true,
  });
};
// 添加规格值
export const addSpecValue = (data) => {
  return Request.get(`/mall/admin/spec/spec_attr_id`, data, {
    isLoading: true,
  });
};
// 分类查询
export const searchClass = (data) => {
  return Request.get(`/mall/admin/pub/category/tree`, data, {
    isLoading: true,
  });
};

// 添加分类
export const addClass = (data) => {
  return Request.post(`/mall/admin/pub/category/add`, data, {
    isLoading: true,
  });
};

// 更新分类
export const updateClass = (data) => {
  return Request.post(`/mall/admin/pub/category/update`, data, {
    isLoading: true,
  });
};
// 更新分类
export const deleteClass = (data) => {
  return Request.post(`/mall/admin/pub/category/delete`, data, {
    isLoading: true,
  });
};

// ******************* 商品列表 *****************

// 获取商品列表
export const getProductList = (data) => {
  return Request.post(`/mall/admin/pub/goods/sku/listJurisdiction`, data, {
    isLoading: true,
  });
};
// 获取商品详情
export const getProductDetail = (data) => {
  return Request.get(`/mall/admin/pub/goods/sku/distinguishShopGoods`, data, {
    isLoading: true,
  });
};
// 获取门店列表
export const getStoreList = (data) => {
  return Request.get(`/mall/admin/pub/store/list`, data, {
    isLoading: true,
  });
};

// 新增商品
export const addProduct = (data) => {
  return Request.post(`/mall/admin/pub/goods/sku/add`, data, {
    isLoading: true,
  });
};

// 更新商品
export const updateProduct = (data) => {
  return Request.post(`/mall/admin/pub/goods/sku/distinguishShopupdate`, data, {
    isLoading: true,
  });
};
// 批量上下架商品
export const batchModifyStatusByGoodsId = (data) => {
  return Request.post(
    `/mall/admin/goods/sku/batchModifyStatusByGoodsId`,
    data,
    {
      isLoading: true,
    }
  );
};
// 删除商品 /mall/admin/goods/sku/delete
export const deleteProduct = (data) => {
  return Request.post(`/mall/admin/goods/sku/delete`, data, {
    isLoading: true,
  });
};
// ******************* 桌码管理 *****************
// 获取区域列表
export const getShopArea = (data) => {
  return Request.get(`/mall/admin/pub/area/getAreaByshopId`, data, {
    isLoading: true,
  });
};
// 添加区域
export const addShopArea = (data) => {
  return Request.post(`/mall/admin/pub/area/insertArea`, data, {
    isLoading: true,
  });
};
// 更新区域
export const updateArea = (data) => {
  return Request.post(`/mall/admin/pub/area/updateArea`, data, {
    isLoading: true,
  });
};
// 删除区域
export const deleteArea = (data) => {
  return Request.post(`/mall/admin/pub/area/deleteArea`, data, {
    isLoading: true,
  });
};

// ******************* 桌台管理 *****************

// 获取桌台列表
export const getTables = (data) => {
  return Request.post(`/mall/admin/pub/table/getTables`, data, {
    isLoading: false,
  });
};
// 增加桌台
export const insertTable = (data) => {
  return Request.post(`/mall/admin/pub/table/insertTable`, data, {
    isLoading: true,
  });
};
// 更新桌台
export const updateTable = (data) => {
  return Request.post(`/mall/admin/pub/table/updateTable`, data, {
    isLoading: true,
  });
};
// 删除桌台
export const deleteTable = (data) => {
  return Request.post(`/mall/admin/pub/table/deleteTable`, data, {
    isLoading: true,
  });
};
// 批量增加桌台
export const batchInsertTable = (data) => {
  return Request.post(`/mall/admin/pub/table/batchInsertTable`, data, {
    isLoading: true,
  });
};
// 绑定桌码
export const bindDesk = (data) => {
  return Request.post(`/wifi_admin/table/bind`, data, {
    isLoading: true,
    callbackOptions: {
      // 返回选项
      all: true, // 是否将response body 全部返回
      errorAll: true, // 是否非成功请求将response body 全部返回
    },
  });
};
// 解绑桌码
export const unBinddesk = (data) => {
  return Request.post(`/wifi_admin/table/unBind`, data, {
    isLoading: true,
  });
};

// ******************* 门店 *****************
export const shopList = (data) => {
  return Request.get(`/mall/admin/pub/store/list`, data, {
    isLoading: false,
  });
};
